<?php

require_once("PHPExcel.php");

Class Excel{
		
    public $excelpath;
	public $excelList;
	
	function __construct($path) {
      $this->excelpath = $path;
	  $this->excelList = array();
	  $objReader = new PHPExcel_Reader_Excel5(); 
	  $objReader->setReadDataOnly(true); 

	  $objPHPExcel = $objReader->load($this->excelpath); 
	  $currentSheet = $objPHPExcel->getSheet(0);
	  $allLine = $currentSheet->getHighestRow();
	  for($excel_line = 2;$excel_line<=$allLine;$excel_line++)
	  {
		   $time_fromat = $currentSheet->getCell("A{$excel_line}")->getValue();
		   $time = date('Y-m-d', PHPExcel_Shared_Date::ExcelToPHP($time_fromat));
		   $context = $currentSheet->getCell("B{$excel_line}")->getValue();
		   array_push($this->excelList, array($time, $context));
		   
	  }
	  unset($objReader);
	  unset($objPHPExcel);
    }
   
	public function getInfList(){
	  return $this->excelList;
	}
	
	public function getInfListByIndex($start, $last){
		$excelList = $this->excelList;
		$excelListIndex = array();
		for($index = $start; $index <= $last; $index++)
		{
		    if(isset($excelList[$index]))
			{
				array_push($excelListIndex,$excelList[$index]);
			}
		}
		return $excelListIndex;
	}
	
	public function getExcelCount(){
		return count($this->excelList);
	}
}

/*$newobject = new News();
$news = $newobject->getNewsListByIndex(2,9);
foreach($news as $newscontext)
{
	echo $newscontext[0] . " ";
	echo $newscontext[1] . "<br />";	
}*/
?>